home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / XAMPP 1.4.14 / xampp-win32-1.4.14-installer.exe / xampp / php / pear / HTML / docs / example.php next >
PHP Script  |  2004-03-24  |  5KB  |  103 lines

  1. <?php
  2. // +-----------------------------------------------------------------------+
  3. // | Copyright (c) 2002-2003, Richard Heyes, Harald Radi                        |
  4. // | All rights reserved.                                                  |
  5. // |                                                                       |
  6. // | Redistribution and use in source and binary forms, with or without    |
  7. // | modification, are permitted provided that the following conditions    |
  8. // | are met:                                                              |
  9. // |                                                                       |
  10. // | o Redistributions of source code must retain the above copyright      |
  11. // |   notice, this list of conditions and the following disclaimer.       |
  12. // | o Redistributions in binary form must reproduce the above copyright   |
  13. // |   notice, this list of conditions and the following disclaimer in the |
  14. // |   documentation and/or other materials provided with the distribution.| 
  15. // | o The names of the authors may not be used to endorse or promote      |
  16. // |   products derived from this software without specific prior written  |
  17. // |   permission.                                                         |
  18. // |                                                                       |
  19. // | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   |
  20. // | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     |
  21. // | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
  22. // | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  |
  23. // | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
  24. // | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      |
  25. // | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
  26. // | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
  27. // | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   |
  28. // | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
  29. // | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  |
  30. // |                                                                       |
  31. // +-----------------------------------------------------------------------+
  32. // | Author: Richard Heyes <richard@phpguru.org>                           |
  33. // |         Harald Radi <harald.radi@nme.at>                              |
  34. // +-----------------------------------------------------------------------+
  35. //
  36. // $Id: example.php,v 1.13 2003/12/20 13:33:10 richard Exp $
  37.  
  38.     require_once('HTML/TreeMenu.php');
  39.     //require_once('../TreeMenu.php');
  40.  
  41.     $icon         = 'folder.gif';
  42.     $expandedIcon = 'folder-expanded.gif';
  43.  
  44.     $menu  = new HTML_TreeMenu();
  45.  
  46.     $node1   = new HTML_TreeNode(array('text' => "First level", 'link' => "test.php", 'icon' => $icon, 'expandedIcon' => $expandedIcon, 'expanded' => true), array('onclick' => "alert('foo'); return false", 'onexpand' => "alert('Expanded')"));
  47.     $node1_1 = &$node1->addItem(new HTML_TreeNode(array('text' => "Second level", 'link' => "test.php", 'icon' => $icon, 'expandedIcon' => $expandedIcon)));
  48.     $node1_1_1 = &$node1_1->addItem(new HTML_TreeNode(array('text' => "Third level", 'link' => "test.php", 'icon' => $icon, 'expandedIcon' => $expandedIcon)));
  49.     $node1_1_1_1 = &$node1_1_1->addItem(new HTML_TreeNode(array('text' => "Fourth level", 'link' => "test.php", 'icon' => $icon, 'expandedIcon' => $expandedIcon)));
  50.     $node1_1_1_1->addItem(new HTML_TreeNode(array('text' => "Fifth level", 'link' => "test.php", 'icon' => $icon, 'expandedIcon' => $expandedIcon, 'cssClass' => 'treeMenuBold')));
  51.  
  52.     $node1->addItem(new HTML_TreeNode(array('text' => "Second level, item 2", 'link' => "test.php", 'icon' => $icon, 'expandedIcon' => $expandedIcon)));
  53.     $node1->addItem(new HTML_TreeNode(array('text' => "Second level, item 3", 'link' => "test.php", 'icon' => $icon, 'expandedIcon' => $expandedIcon)));
  54.  
  55.     $menu->addItem($node1);
  56.     $menu->addItem($node1);
  57.     
  58.     // Create the presentation class
  59.     $treeMenu = &new HTML_TreeMenu_DHTML($menu, array('images' => '../images', 'defaultClass' => 'treeMenuDefault'));
  60.     $listBox  = &new HTML_TreeMenu_Listbox($menu, array('linkTarget' => '_self'));
  61. ?>
  62. <html>
  63. <head>
  64.     <style type="text/css">
  65.         body {
  66.             font-family: Georgia;
  67.             font-size: 11pt;
  68.         }
  69.         
  70.         .treeMenuDefault {
  71.             font-style: italic;
  72.         }
  73.         
  74.         .treeMenuBold {
  75.             font-style: italic;
  76.             font-weight: bold;
  77.         }
  78.     </style>
  79.     <script src="TreeMenu.js" language="JavaScript" type="text/javascript"></script>
  80. </head>
  81. <body>
  82.  
  83. <script language="JavaScript" type="text/javascript">
  84. <!--
  85.     a = new Date();
  86.     a = a.getTime();
  87. //-->
  88. </script>
  89.  
  90. <?$treeMenu->printMenu()?>
  91. <?$listBox->printMenu()?>
  92.  
  93. <script language="JavaScript" type="text/javascript">
  94. <!--
  95.     b = new Date();
  96.     b = b.getTime();
  97.     
  98.     document.write("Time to render tree: " + ((b - a) / 1000) + "s");
  99. //-->
  100. </script>
  101. </body>
  102. </html>
  103.